package demo3;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-11-14
 * Time: 20:12
 */

interface IFlying {
    void fly();
}

interface ISwimming {
    void swim();
}

interface IRunning {
    void run();
}


abstract class Animal {

    private String name;

    private int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public abstract void eat();
}

class Dog extends Animal implements IRunning, ISwimming {


    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void swim() {
        System.out.println(this.getName() + "正在狗刨!");
    }

    @Override
    public void run() {
        System.out.println(this.getName() + "正在跑步!");
    }

    @Override
    public void eat() {
        System.out.println(this.getName() + "正在吃狗粮!");
    }
}

class Bird extends Animal implements IFlying {

    public Bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void fly() {
        System.out.println(this.getName() + "正在用翅膀飞!");
    }

    @Override
    public void eat() {
        System.out.println(this.getName() + "正在吃鸟量!");
    }
}

class Robot implements IRunning {

    @Override
    public void run() {
        System.out.println("机器人在跑!");
    }
}


public class Test {

    public static void test1(Animal animal) {
        animal.eat();
    }

    public static void testFly(IFlying iFlying) {
        iFlying.fly();
    }

    public static void testRun(IRunning running) {
        running.run();
    }

    public static void testSwim(ISwimming iSwimming) {
        iSwimming.swim();
    }


    public static void main(String[] args) {
        testFly(new Bird("小鸟", 2));
        testRun(new Dog("小狗", 1));
        testSwim(new Dog("小狗", 1));
        testRun(new Robot());
    }

    public static void main1(String[] args) {
        test1(new Dog("小狗", 1));
        test1(new Bird("小鸟", 2));
    }
}

interface A {
    void testA();
}

interface B {
    void testB();
}
//扩展功能！
interface C extends A,B {
    void testC();
}
class D implements C {

    @Override
    public void testA() {

    }

    @Override
    public void testB() {

    }

    @Override
    public void testC() {

    }
}